东航航空货运系统(四)功能模块_制单管理_1

来源:互联网 发布:linux boot 文件详解 编辑:程序博客网 时间:2024/04/29 14:53

<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">制单管理:主要功能是进行国际正式制单</span><span style="font-family: 'Times New Roman'; background-color: rgb(255, 255, 255);">,</span><span style="font-family: 宋体; background-color: rgb(255, 255, 255);">国际公务制单及运单承运信息,日志信息不正常登记信息的查询,运单的修改,作废等处理。当在制单页面输入运单号按</span><span style="font-family: 'Times New Roman'; background-color: rgb(255, 255, 255);">Tab</span><span style="font-family: 宋体; background-color: rgb(255, 255, 255);">键,若运单号已制单则可以提取相关信息,若还没进行制单则可以进行制单操作。运单在生成后的操作中的操作会生成运单日志,在运单查询页面可查看。</span>

1.8.1提取已制单运单信息

   在输入运单号码时,系统会根据用户输入的数字自动检索出已制单的运单号码,选中已制单号码按Tab键可提取出运单制单信息。


1.8.1(图1)


1.8.1(图2)

从界面上可以看到我们这里用到的控件有 

控件名称

说明

下拉框(ComboBox)

选择数据类型

文本框(TextBox)

输入制单内容

按钮(Button)

实现对应功能

表格(DataGridView)

承载数据


第一步:数据库

   这是制单模块涉及的主要操作表:


1.8.1(图3)

dbo.PW_WaybillTable

主键(s):  WaybillID

列名

数据类型

Nulls?

说明

WaybillID

int - Identity

No

运单ID

 

WaybillMarkPrefix

nchar (10)

Yes

运单号前缀

 

WaybillNumber

nchar (20)

Yes

运单号码

 

InceptionPointID

int

Yes

起点站ID

 

CarrierID1

int

Yes

承运人ID1

 

ArrivePointID1

int

Yes

到达站ID1

 

CarrierID2

int

Yes

承运人ID2

 

ArrivePointID2

int

Yes

到达站ID2

 

CarrierID3

int

Yes

承运人ID3

 

ArrivePointID3

int

Yes

到达站ID3

 

ObjectiveStandID

int

Yes

目的站ID

 

DeliverGoodsID

int

Yes

发货人ID

 

ConsigneeID

int

Yes

收货人ID

 

AttributeList_WeightUnitID

nchar (10)

Yes

重量单位ID

 

AttributeList_VolumeUnitID

nchar (10)

Yes

体积单位ID

 

CargoTypeID

int

Yes

货物类型ID

 

PackTypeID

int

Yes

包装类型ID

 

AlwaysCargoName

nchar (100)

Yes

总货物品名

 

AlwaysCargoNumber

nchar (10)

Yes

总货物件数

 

AlwaysSLACNumber

nchar (10)

Yes

总SLAC件数

 

TotalVolume

nchar (10)

Yes

总体积

 

AlwaysWeight

nchar (10)

Yes

总重量

 

GrossFeeWeight

nchar (10)

Yes

总计费重量

 

AlwaysFreight

nchar (100)

Yes

总运价

 

AttributeList_WaybillStateID

nchar (10)

Yes

运单状态ID

 

WaybillTypeID

int

Yes

运单类型ID

 

InsureStatementValue

nchar (10)

Yes

保险声明价值

 

SettleAccountsAttention

nchar (50)

Yes

结算注意

 

PickUpGoodsDoBusineessDotID

int

Yes

提货营业点ID

 

TransportStatementValue

nchar (10)

Yes

运输声明价值

 

SecurityOfficer

nchar (10)

Yes

安检员

 

CustomsStatementValue

nchar (10)

Yes

海关声明价值

 

AttributeList_InceptionPointCoinSeedID

nchar (10)

Yes

起点站币种ID

 

AttributeList_ObjectiveStandCoinSeedID

nchar (10)

Yes

目的站币种ID

 

Parities

decimal (18, 2)

Yes

汇率

 

StoreAnnouncementsInformationID

int

Yes

储运注意事项信息ID

 

InceptionPointStorageID

int

Yes

起点站点仓库ID

 

ObjectiveStandStorageID

int

Yes

目的站点仓库ID

 

MakeSinglePerson

nchar (10)

Yes

制单人

 

MakeSingleTime

datetime

Yes

制单时间

 

MakeSingleDoBusineessDot

nchar (20)

Yes

制单营业点

 

SupervisionNo

bit

No

监管否

 

SecurityNo

bit

Yes

安检否

 

ArrivePayNo

bit

Yes

到付否

 

HangClothingNo

bit

Yes

挂衣否

 

UnusualNo

bit

Yes

异常否

 

CancelNo

bit

Yes

作废否

 

Remark

nchar (100)

Yes

备注

 

FreePublicNo

bit

Yes

免费公务否

 

PublicCarrier

nchar (10)

Yes

公免承运人

 

PublicFlightNumber

nchar (10)

Yes

公免航班号

 

PublicFlightDate

date

Yes

公免航班日期

 

TurnHarborOn

bit

Yes

 


  

dbo.PW_WanbillDetailsTable

主键(s):  WanbillDetailsID

列名

数据类型

Nulls?

说明

WanbillDetailsID

int - Identity

No

运单明细ID

 

WaybillID

int

Yes

运单ID

 

CargoNameID

int

Yes

货物品名ID

 

CargoNumber

nchar (10)

Yes

货物件数

 

Weight

 

nchar (10)

Yes

重量

 

Size

decimal (18, 2)

Yes

尺寸

 

Volume

nchar (10)

Yes

体积

 

FeeWeight

nchar (10)

Yes

计费重量

 

Freight

nchar (100)

Yes

运价

 

AttributeList_AppointTreatyID

nchar (10)

Yes

指定协议ID

 

AttributeList_CarryPriceTypeID

nchar (10)

Yes

运价种类ID

 

CancelNo

bit

Yes

作废否

1.8.2国际正式制单                          

  步骤: 输入未制单号码,输入业务信息制单(底色为淡黄色的文本框可双击选择)  

(1)选择运单货物起点站,已经在其他文本框选择了的站点不能再选择为其他站点,承运人为站点相应的承运营业点。

(2)客户可在客户简称文本框双击显示所有客户信息,也可以输入客户简称后按Tab提取出客户信息,若数据库没有该客户信息,系统提示用户是否添加。

(3)双击DGV里’代码’那一列或点击’添加’按钮,显示货物列表选择。在选择货物的重量单位,体积单位和协议种类,运价种类后,按’自动运单’按钮,系统会自动计算出货物的运价,总运价=货物运价+货物运价X其他费用的费率。

(4)作废运单,运单界面中控件都被禁用,只有几个功能按钮可以使用

 功能实现:

(1)窗体加载时绑定下拉框数据

 第一步:数据库存数过程 

IF(@Type='FRM_InternationalOfficialMakeBill_SelectWeightUnit')--绑定重量单位BEGIN   SELECT  RTRIM(SYS_AttributeListTable.AttributeListName) AS AttributeListName, SYS_AttributeListTable.AttributeListIDFROM         SYS_AttributeListTable INNER JOIN                      SYS_AttributeSetsTable ON SYS_AttributeListTable.AttributeSetsID = SYS_AttributeSetsTable.AttributeSetsIDWHERE SYS_AttributeSetsTable.AttributeSetsID=5END 

第二步:逻辑层(BLL)代码

#region  查询重量单位        [OperationContract]        public DataSet FRM_InternationalOfficialMakeBill_SelectWeightUnit()        {            SqlParameter[] mySqlParameters = {                                              new SqlParameter("@Type", SqlDbType.Char),                                             };            mySqlParameters[0].Value = "FRM_InternationalOfficialMakeBill_SelectWeightUnit";            DataTable myDataTable = myDALMethod.QueryDataTable("制单管理_FRM_InternationalOfficialMakeBill", mySqlParameters);            DataSet myDataSet = new DataSet();            myDataSet.Tables.Add(myDataTable);            return myDataSet;        }        #endregion

第三步:界面层(UIL)代码

cboWeightUnit.DataSource = myFRM_InternationalOfficialMakeBillClient.FRM_InternationalOfficialMakeBill_SelectWeightUnit().Tables[0];            cboWeightUnit.DisplayMember = "AttributeListName";            cboWeightUnit.ValueMember = "AttributeListID";

(2)窗体加载时绑定可选择数据列表

IF(@Type='FRM_InternationalOfficialMakeBill_SelectClient')--查询客户信息BEGIN  SELECT     ClientID, ClientCode, ClientAbbreviation, PracticePhone, PracticeAddress, ClientNameFROM         SYS_ClientTableEND

第二步:逻辑层(BLL)代码

#region  查询客户        [OperationContract]        public DataSet FRM_InternationalOfficialMakeBill_SelectClient()        {            SqlParameter[] mySqlParameters = {                                           new SqlParameter("@Type", SqlDbType.Char),                                          };            mySqlParameters[0].Value = "FRM_InternationalOfficialMakeBill_SelectClient";            DataTable myDataTable = myDALMethod.QueryDataTable("制单管理_FRM_InternationalOfficialMakeBill", mySqlParameters);            DataSet myDataSet = new DataSet();            myDataSet.Tables.Add(myDataTable);            return myDataSet;        }        #endregion

第三步:界面层(UIL)代码

dgvClient.AutoGenerateColumns = false;//禁止添加列            dgvClient.AllowUserToAddRows = false;//禁止显示添加行            dgvClient.DataSource = myFRM_InternationalOfficialMakeBillClient.FRM_InternationalOfficialMakeBill_SelectClient().Tables[0];

(3)窗体加载时代码生成’其他费用的dgv’:

 第一步:数据库存数过程

 IF(@Type='FRM_InternationalOfficialMakeBill_SelectCostRate')--查询其他费用  BEGIN     SELECT     CostID, CostName, CostRateFROM         SYS_CostTable  END 

第二步:逻辑层(BLL)代码

#region 查询其他费用        [OperationContract]        public DataSet FRM_InternationalOfficialMakeBill_SelectCostRate()        {            SqlParameter[] mySqlParameters = {                                             new SqlParameter("@Type", SqlDbType.Char),                                                                                     };            mySqlParameters[0].Value = "FRM_InternationalOfficialMakeBill_SelectCostRate";            DataTable myDataTable = myDALMethod.QueryDataTable("制单管理_FRM_InternationalOfficialMakeBill", mySqlParameters);            DataSet myDataSet = new DataSet();            myDataSet.Tables.Add(myDataTable);            return myDataSet;        }        #endregion

第三步:界面层(UIL)代码

dgvFreight.AutoGenerateColumns = false;            dgvFreight.AllowUserToAddRows = false;            DataTable dtCostRate = myFRM_InternationalOfficialMakeBillClient.FRM_InternationalOfficialMakeBill_SelectCostRate().Tables[0];            for (int i = 0; i < dtCostRate.Rows.Count+1; i++)            {                if (i < dtCostRate.Rows.Count)                {                    dgvFreight.Rows.Add();                    dgvFreight.Rows[i].Cells["其他费用"].Value = dtCostRate.Rows[i]["CostName"].ToString().Trim();                    dgvFreight.Rows[i].Cells["费率"].Value = dtCostRate.Rows[i]["CostRate"].ToString().Trim();                }                if (i == dtCostRate.Rows.Count)                {                    dgvFreight.Rows.Add();                    dgvFreight.Rows[dtCostRate.Rows.Count].Cells["其他费用"].Value = "总计";                }            }  

(4)文本框的检索功能:

第一步:数据库查询已制单号码

IF(@Type='FRM_InternationalOfficialMakeBill_SelectAllWaybillNumber')--查询所有非公免运单号  BEGIN      SELECT     WaybillNumber      FROM         PW_WaybillTable      WHERE PW_WaybillTable.WaybillMarkPrefix=@WaybillMarkPrefix AND PW_WaybillTable.FreePublicNo=0  END

第二步:逻辑层(BLL)代码

#region 查询所有非公免运单号        [OperationContract]        public DataSet FRM_InternationalOfficialMakeBill_SelectAllWaybillNumber(string WaybillMarkPrefix)        {            SqlParameter[] mySqlParameters = {                                             new SqlParameter("@Type",SqlDbType.Char),                                             new SqlParameter("@WaybillMarkPrefix", SqlDbType.Char),                                         };            mySqlParameters[0].Value = "FRM_InternationalOfficialMakeBill_SelectAllWaybillNumber";            mySqlParameters[1].Value = WaybillMarkPrefix;            DataTable myDataTable = myDALMethod.QueryDataTable("制单管理_FRM_InternationalOfficialMakeBill", mySqlParameters);            DataSet myDataSet = new DataSet();            myDataSet.Tables.Add(myDataTable);            return myDataSet;        }        #endregion

第三步:界面层(UIL)代码

#region 检索运单号码        private void txtWaybillNumber_TextChanged(object sender, EventArgs e)        {            try            {                if (txtWaybillNumber.Text.Length > 0)                {                    DataTable dtAllWaybillNumber = new DataTable();                    string strWaybillMarkPrefix = txtWaybillMarkPrefix.Text.ToString().Trim();                    string strWaybillNumber1 = txtWaybillNumber.Text.ToString().Trim();                    //从数据库查询                    dtAllWaybillNumber = myFRM_InternationalOfficialMakeBillClient.FRM_InternationalOfficialMakeBill_SelectAllWaybillNumber(strWaybillMarkPrefix).Tables[0];                    //声明一个数组,长度是dtAllWaybillNumber的总行数                    string[] strWaybillNumber = new string[dtAllWaybillNumber.Rows.Count];                    for (int i = 0; i < dtAllWaybillNumber.Rows.Count; i++)                    {                        strWaybillNumber[i] = dtAllWaybillNumber.Rows[i]["WaybillNumber"].ToString().Trim();                    }                    txtWaybillNumber.AutoCompleteSource = AutoCompleteSource.CustomSource;//为TextBox指定为自定义源                    txtWaybillNumber.AutoCompleteCustomSource.AddRange(strWaybillNumber);//将数组添加进源                    txtWaybillNumber.AutoCompleteMode = AutoCompleteMode.Suggest;//为用户完成源并显示下拉框给用户选择                }            }            catch { }        }        #endregion  

(5)已经选择的站点不能再选择为其他站点类型

#region 自定义方法限制已经选择的站点不能再选        /// <summary>        ///         /// </summary>        /// <param name="myTextBox">进行操作的文本框</param>        /// <param name="strType">判断文本框输入类型</param>         List<int> myList=new List<int>();//用于记录已经选择的站点        private void OpinionTextBox(TextBox myTextBox, string strType)        {            if (strShuangJiLeiXing == strType)//判断是哪个文本框进行操作            {                if (myTextBox.Text == "")//文本框还没进行过选择                {                    if (myList.Count > 0)//其他文本框进行了选择                    {                        //如果myList里存在与当前选择的站点相同的ID                        if (myList.Exists(i => i == Convert.ToInt32(dgvSite.CurrentRow.Cells["站点ID"].Value.ToString().Trim())))                        { }                        else                        {//如果myList里不存在与当前选择的站点的ID                            myTextBox.Text = dgvSite.CurrentRow.Cells["站点简称"].Value.ToString().Trim();                            myTextBox.Tag = dgvSite.CurrentRow.Cells["站点ID"].Value.ToString().Trim();                            myList.Add(Convert.ToInt32(dgvSite.CurrentRow.Cells["站点ID"].Value.ToString().Trim()));//把选择的站点ID加进myList                            panSite.Visible = false;                        }                    }                    else                    {     //其他文本框没有进行过选择                        myTextBox.Text = dgvSite.CurrentRow.Cells["站点简称"].Value.ToString().Trim();                        myTextBox.Tag = dgvSite.CurrentRow.Cells["站点ID"].Value.ToString().Trim();                        myList.Add(Convert.ToInt32(dgvSite.CurrentRow.Cells["站点ID"].Value.ToString().Trim()));                        panSite.Visible = false;                    }                }                else                {                    int myTextBoxID = Convert.ToInt32(myTextBox.Tag);                    //如果myList里存在与当前选择的站点相同的ID                    if (myList.Exists(i=>i == Convert.ToInt32(dgvSite.CurrentRow.Cells["站点ID"].Value.ToString().Trim())))                    { }                    else                    {                        //如果myList里存在与当前选择的站点相同的ID就把它移除myList                        if (myList.Exists(i => i == myTextBoxID))                        {                            myList.Remove(myTextBoxID);                        }                        myTextBox.Text = dgvSite.CurrentRow.Cells["站点简称"].Value.ToString().Trim();                        myTextBox.Tag = dgvSite.CurrentRow.Cells["站点ID"].Value.ToString().Trim();                        myList.Add(Convert.ToInt32(dgvSite.CurrentRow.Cells["站点ID"].Value.ToString().Trim()));                        panSite.Visible = false;                    }                                    }            }        }        #endregion       

(6)客户管理

 第一步:数据库存储过程    

IF(@Type='FRM_InternationalOfficialMakeBill_SelectClientInformation')--根据客户简称查询客户信息  BEGIN     SELECT     ClientCode, ClientName, ClientAbbreviation, PracticePhone, PracticeAddress, ClientIDFROM         SYS_ClientTable     WHERE SYS_ClientTable.ClientAbbreviation=@ClientAbbreviation  END IF(@Type='FRM_InternationalOfficialMakeBill_InsertClient')--新增客户  BEGIN     INSERT SYS_ClientTable(AttributeList_ClientTypeID, ClientCode,ClientName, ClientAbbreviation, PracticePhone,PracticeAddress,BankAccount,ClientInformation)     VALUES (@AttributeList_ClientTypeID, @ClientCode,@ClientName, @ClientAbbreviation, @PracticePhone,@PracticeAddress,@BankAccount,@ClientInformation)           END 

第二步:逻辑层(BLL)代码

#region 根据客户简称查询客户信息        [OperationContract]        public DataSet FRM_InternationalOfficialMakeBill_SelectClientInformation(string  ClientAbbreviation)        {            SqlParameter[] mySqlParameters = {                                             new SqlParameter("@Type", SqlDbType.Char),                                             new SqlParameter("@ClientAbbreviation", SqlDbType.Char),                                         };            mySqlParameters[0].Value = "FRM_InternationalOfficialMakeBill_SelectClientInformation";            mySqlParameters[1].Value = ClientAbbreviation;            DataTable myDataTable = myDALMethod.QueryDataTable("制单管理_FRM_InternationalOfficialMakeBill", mySqlParameters);            DataSet myDataSet = new DataSet();            myDataSet.Tables.Add(myDataTable);            return myDataSet;        }        #endregion

 第三步:界面层(UIL)代码

 private void txtAbbreviation_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)        {            if ((Keys)e.KeyCode == Keys.Tab)//如果用户按下Tab键            {                if (txtAbbreviation.Text != "")                {                    string strAbbreviation = txtAbbreviation.Text.ToString().Trim();                    DataTable dtClientInformation = myFRM_InternationalOfficialMakeBillClient.FRM_InternationalOfficialMakeBill_SelectClientInformation(strAbbreviation).Tables[0];                    if (dtClientInformation.Rows.Count > 0)//该用户简称存在相关信息                    {                        if (dtClientInformation.Rows.Count < 2)//该用户简称存在相关信息只涉及一个用户时                        {                                                        string strClientCode = dtClientInformation.Rows[0]["ClientCode"].ToString().Trim();                            string strClientName = dtClientInformation.Rows[0]["ClientName"].ToString().Trim();                            string strPracticePhone = dtClientInformation.Rows[0]["PracticePhone"].ToString().Trim();                            string strPracticeAddress = dtClientInformation.Rows[0]["PracticeAddress"].ToString().Trim();                            txtShipmentsPerson.Text = strClientCode;                            txtDeliverGoodsInformation.Text = "客户全称:" + strClientName + "\t" + "联系电话:" + strPracticePhone + "\t" + "联系地址:" + strPracticeAddress;                        }                        else   //该用户简称存在相关信息不止涉及一个用户时,显示列表                        {                            strShuangJiLeiXing = "发货人简称1";                            for (int i = 0; i < dtClientInformation.Rows.Count; i++)                            {                                                             dgvClient.Rows.Add();                                dgvClient.Rows[i].Cells["客户代码"].Value = dtClientInformation.Rows[i]["ClientCode"].ToString().Trim();                                dgvClient.Rows[i].Cells["客户简称"].Value = dtClientInformation.Rows[i]["ClientAbbreviation"].ToString().Trim();                                dgvClient.Rows[i].Cells["客户全称"].Value = dtClientInformation.Rows[i]["ClientName"].ToString().Trim();                                dgvClient.Rows[i].Cells["联系电话1"].Value = dtClientInformation.Rows[i]["PracticePhone"].ToString().Trim();                                dgvClient.Rows[i].Cells["联系地址"].Value = dtClientInformation.Rows[i]["PracticeAddress"].ToString().Trim();                                dgvClient.Rows[i].Cells["客户ID"].Value = dtClientInformation.Rows[i]["ClientID"].ToString().Trim();                            }                                panClien.Visible = true;                        }                    }                    else                    {                        if (MessageBox.Show("系统没有检测到该客户简称记录的客户信息,是否需要新增?", "系统提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK)                        {                            FRM_InsertClientInformation myFRM_InsertClientInformation = new FRM_InsertClientInformation(strAbbreviation);                            myFRM_InsertClientInformation.ShowDialog();                        }                    }                }            }        }

(7)双击‘代码’那一列显示货物列表,实现传值

 第一步:数据库存储过程

IF(@Type='FRM_InternationalOfficialMakeBill_SelectCargoName')--查询货物品名BEGIN  SELECT     CargoNameID, Code, ChineseName, EnglishName, NameDescribeFROM         SYS_CargoNameTableEND

第二步:逻辑层(BLL)代码

#region  查询货物品名        [OperationContract]        public DataSet FRM_InternationalOfficialMakeBill_SelectCargoName()        {            SqlParameter[] mySqlParameters = {                                           new SqlParameter("@Type", SqlDbType.Char),                                          };            mySqlParameters[0].Value = "FRM_InternationalOfficialMakeBill_SelectCargoName";            DataTable myDataTable = myDALMethod.QueryDataTable("制单管理_FRM_InternationalOfficialMakeBill", mySqlParameters);            DataSet myDataSet = new DataSet();            myDataSet.Tables.Add(myDataTable);            return myDataSet;        }        #endregion

第三步:界面层(UIL)代码

 #region  弹出窗口        private void dgvHuoWuXinXi_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)        {            //获取当前活动单元格的列索引            int cellIndex = dgvCragoInformation.CurrentCell.ColumnIndex;            if (cellIndex == 0)//如果是第一列            {                //显示货物列表,并把dgv传到货物列表的窗体                FRM_CargoName myFRM_HuoWuPinMing = new FRM_CargoName(this.dgvCragoInformation);                myFRM_HuoWuPinMing.ShowDialog();            }        }        #endregion private void dgvHuoWuPinMing_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)        {            if (dgvHuoWuXinXi.CurrentRow != null)            {                try                {                    //获取当前行索引                    int rowIndex = dgvHuoWuXinXi.CurrentRow.Index;                    //判断是为修改一行数据,还是新增一条                    if (dgvHuoWuXinXi.Rows[rowIndex].Cells["代码"].Value == null)                    {                        dgvHuoWuXinXi.Rows.Add();                    }                    //赋值dgv                    dgvHuoWuXinXi.CurrentRow.Cells["代码"].Value = dgvCagroName.CurrentRow.Cells["代码"].Value;                    dgvHuoWuXinXi.CurrentRow.Cells["名称"].Value = dgvCagroName.CurrentRow.Cells["中文名称"].Value;                     dgvHuoWuXinXi.CurrentRow.Cells["货物品名ID"].Value = dgvCagroName.CurrentRow.Cells["货物品名ID"].Value;                    dgvHuoWuXinXi.CurrentRow.Cells["重量"].Value = 1;                    dgvHuoWuXinXi.CurrentRow.Cells["件数"].Value = 1;                    dgvHuoWuXinXi.CurrentRow.Cells["体积"].Value = 0;                    dgvHuoWuXinXi.CurrentRow.Cells["计费重量"].Value = 1;                    this.Close();//关闭货物列表窗体                }                catch { }            }        }

(8)自动运价

第一步:数据库存储过程 

 IF(@Type='FRM_InternationalOfficialMakeBill_SelectCargoFreight')--查询货物运价  BEGIN      SELECT     CargoNameID, AttributeList_AppointTreatyID, AttributeList_FreightTypeID, FreightFROM         SYS_CargoFreightTableWHERE CargoNameID=@CargoNameID AND AttributeList_AppointTreatyID=@AttributeList_AppointTreatyID AND AttributeList_FreightTypeID=@AttributeList_FreightTypeID  END 

第二步:逻辑层(BLL)代码

 #region 查询货物运价        [OperationContract]        public DataSet FRM_InternationalOfficialMakeBill_SelectCargoFreight(int CargoNameID, int AppointTreatyID, int FreightTypeID)        {            SqlParameter[] mySqlParameters = {                                             new SqlParameter("@Type", SqlDbType.Char),                                            new SqlParameter("@CargoNameID", SqlDbType.Int),                                            new SqlParameter("@AttributeList_AppointTreatyID", SqlDbType.Int),                                            new SqlParameter("@AttributeList_FreightTypeID", SqlDbType.Int),                                        };            mySqlParameters[0].Value = "FRM_InternationalOfficialMakeBill_SelectCargoFreight";            mySqlParameters[1].Value = CargoNameID;            mySqlParameters[2].Value = AppointTreatyID;            mySqlParameters[3].Value = FreightTypeID;            DataTable myDataTable = myDALMethod.QueryDataTable("制单管理_FRM_InternationalOfficialMakeBill", mySqlParameters);            DataSet myDataSet = new DataSet();            myDataSet.Tables.Add(myDataTable);            return myDataSet;        }        #endregion

 第三步:界面层(UIL)代码  

#region 自动运价        private void AutomaticTransportPrice_Click(object sender, EventArgs e)        {            if (dgvCragoInformation.Rows.Count > 1)//dgv的行大于1,即选择了货物            {                try                {                    //声明计算变量                    string strCargoFreight = "";                    decimal decAllCargoFreight = 0;//总货物运价                    decimal decAllOutlay = 0;                    for (int i = 0; i < dgvCragoInformation.Rows.Count - 1; i++)                    {                        int intCargoNameID = Convert.ToInt32(dgvCragoInformation.Rows[i].Cells["货物品名ID"].Value.ToString().Trim());                        int intAppointTreatyID = Convert.ToInt32(dgvCragoInformation.Rows[i].Cells["指定协议"].Value.ToString().Trim());                        int intFreightTypeID = Convert.ToInt32(dgvCragoInformation.Rows[i].Cells["运价种类"].Value.ToString().Trim());                        string strWeight = dgvCragoInformation.Rows[i].Cells["计费重量"].Value.ToString().Trim();                        //根据界面条件查询货物是否有符合条件的计算                        DataTable dtCargoFreight = myFRM_InternationalOfficialMakeBillClient.FRM_InternationalOfficialMakeBill_SelectCargoFreight(intCargoNameID, intAppointTreatyID, intFreightTypeID).Tables[0];                        if (dtCargoFreight.Rows.Count > 0)//有符合计算条件的                        {                            string strFreight = dtCargoFreight.Rows[0]["Freight"].ToString().Trim();                            if (Convert.ToInt32(cboWeightUnit.SelectedValue) == 22)//重量单位是g                            {                                strFreight = (Convert.ToDecimal(strFreight) / 1000).ToString().Trim();                            }                            if (Convert.ToInt32(cboWeightUnit.SelectedValue) == 23)//重量单位是T                            {                                strFreight = (Convert.ToDecimal(strFreight) * 1000).ToString().Trim();                            }                            //货物运价等于运价乘以计费重量                            strCargoFreight = (Convert.ToDecimal(strFreight) * Convert.ToDecimal(strWeight)).ToString().Trim();                            dgvCragoInformation.Rows[i].Cells["运价"].Value = strCargoFreight;                                                    }                        else                        {                            MessageBox.Show("该货物在此条件下还没有定义运价,可在运价管理中添加", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);                            return;                        }                        decAllCargoFreight += Convert.ToDecimal(strCargoFreight);                    }                    for (int j = 0; j < dgvFreight.Rows.Count; j++)//按照货物运价乘以费率计算其他费用                    {                        if (j < dgvFreight.Rows.Count - 1)                        {                            string strCost = dgvFreight.Rows[j].Cells["费率"].Value.ToString().Trim();                            string strOutlay = (Convert.ToDecimal(strCost) * Convert.ToDecimal(decAllCargoFreight)).ToString().Trim();                            dgvFreight.Rows[j].Cells["费用"].Value = strOutlay;                            decAllOutlay += Convert.ToDecimal(strOutlay);//总的其他费用和                        }                        if (j == dgvFreight.Rows.Count-1)                        {                            //计算总的其他费用的和                            dgvFreight.Rows[j].Cells["费用"].Value = decAllOutlay.ToString().Trim();                        }                    }                    txtAllFreight.Text = (decAllCargoFreight + decAllOutlay).ToString().Trim();                }                catch { }                                }            else            {                MessageBox.Show("请选择货物!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);                return;            }                    }        #endregion
*********仅供参考学习用途********


















































0 0
原创粉丝点击