Exemplo n.º 1
0
 protected void uiGridViewShipping_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "DeleteShipping")
     {
         ShippingLines objData = new ShippingLines();
         objData.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString()));
         objData.MarkAsDeleted();
         objData.Save();
         BindData();
     }
 }
Exemplo n.º 2
0
        protected void uiLinkButtonAdd_Click(object sender, EventArgs e)
        {
            ShippingLines objData = new ShippingLines();
            objData.AddNew();
            objData.CompanyID = Convert.ToInt32(uiDropDownListCompanies.SelectedValue);
            objData.FromSeaPortID = Convert.ToInt32(uiDropDownListFromCity.SelectedValue);
            objData.ToSeaPortID = Convert.ToInt32(uiDropDownListToCity.SelectedValue);
            objData.Save();

            BindData();
        }
Exemplo n.º 3
0
        protected void uiLinkButtonUpload_Click(object sender, EventArgs e)
        {
            if (uiFileUploadshippingLines.HasFile)
            {
                ArrayList nonUploaded = new ArrayList();
                uiFileUploadshippingLines.SaveAs(Server.MapPath("~/FileUploads/" + uiFileUploadshippingLines.FileName));
                string connectionString = string.Format(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=""Excel 12.0;HDR=NO;""", Server.MapPath("~/FileUploads/" + uiFileUploadshippingLines.FileName));

                string strSQL = "SELECT * FROM [sheet1$]";
                OleDbConnection excelConnection = new OleDbConnection(connectionString);
                excelConnection.Open();
                OleDbCommand dbCommand = new OleDbCommand(strSQL, excelConnection);
                OleDbDataAdapter dataAdapter = new OleDbDataAdapter(dbCommand);

                DataTable dTable = new DataTable();

                dataAdapter.Fill(dTable);
                ShippingLines objData = new ShippingLines();
                if (uiDropDownListUploadType.SelectedValue == "1")
                {

                    foreach (DataRow item in dTable.Rows)
                    {
                        SeaPorts Fcity = new SeaPorts();
                        Fcity.GetSeaPortByCode(item[0].ToString());

                        SeaPorts Tcity = new SeaPorts();
                        Tcity.GetSeaPortByCode(item[1].ToString());

                        if (Fcity.RowCount == 0 || Tcity.RowCount == 0)
                        {
                            nonUploaded.Add("From : " + item[0].ToString() + " - To : " + item[1].ToString());
                            continue;
                        }
                        else
                        {
                            objData.AddNew();
                            objData.CompanyID = Convert.ToInt32(uiDropDownListUploadCompany.SelectedValue);
                            objData.FromSeaPortID = Fcity.SeaPortID;
                            objData.ToSeaPortID = Tcity.SeaPortID;
                        }
                    }
                }
                else if (uiDropDownListUploadType.SelectedValue == "2")
                {

                    foreach (DataRow item in dTable.Rows)
                    {

                        SeaPorts Fcity = new SeaPorts();
                        Fcity.GetSeaPortByName(item[0].ToString());

                        SeaPorts Tcity = new SeaPorts();
                        Tcity.GetSeaPortByName(item[1].ToString());

                        if (Fcity.RowCount == 0 || Tcity.RowCount == 0)
                        {
                            nonUploaded.Add("From : " + item[0].ToString() + " - To : " + item[1].ToString());
                            continue;
                        }
                        else
                        {
                            objData.AddNew();
                            objData.CompanyID = Convert.ToInt32(uiDropDownListUploadCompany.SelectedValue);
                            objData.FromSeaPortID = Fcity.SeaPortID;
                            objData.ToSeaPortID = Tcity.SeaPortID;
                        }
                    }
                }

                objData.Save();
                BindData();

                uiGridViewLog.DataSource = nonUploaded;
                //uiGridViewLog.Columns[0].HeaderText = "These items faild to insert";
                uiGridViewLog.DataBind();
            }
        }
Exemplo n.º 4
0
 private void BindData()
 {
     ShippingLines objData = new ShippingLines();
     objData.LoadAll();
     uiGridViewShipping.DataSource = objData.DefaultView;
     uiGridViewShipping.DataBind();
 }