Пример #1
0
        /// <summary>
        /// This method is used to save the record.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnsave_Click(object sender, System.EventArgs e)
        {
            try
            {
                if (ListEmpAssigned.Items.Count == 0)
                {
                    MessageBox.Show("Customer Assigned List Not Empty");
                    return;
                }
                InventoryClass obj     = new InventoryClass();
                SqlDataReader  SqlDtr  = null;
                SqlDataReader  SqlDtr1 = null;
                obj.foid = lblschid.Text;
                if (txtschname.Text.Equals(""))
                {
                    obj.discription = "";
                }
                else
                {
                    obj.discription = txtschname.Text.ToString();
                }
                obj.custtype = DropShiftID.SelectedItem.Text.ToString();
                if (txtrs.Text.Equals(""))
                {
                    obj.discount = "";
                }
                else
                {
                    obj.discount = txtrs.Text.ToString();
                }
                obj.discounttype = dropdiscount.SelectedItem.Text.ToString();
                obj.dateto       = System.Convert.ToDateTime(GenUtil.str2DDMMYYYY(Request.Form["txtDateTo"].ToString()));
                obj.datefrom     = System.Convert.ToDateTime(GenUtil.str2DDMMYYYY(Request.Form["txtDateFrom"].ToString()));
                for (int i = 0; i < ListEmpAssigned.Items.Count; ++i)
                {
                    if (Checkfoe.Checked)
                    {
                        int k = Listprodassign.Items.Count;
                        if (k == 0)
                        {
                            MessageBox.Show("Please Select The Product");
                            return;
                        }
                    }
                }

                for (int i = 0; i < ListEmpAssigned.Items.Count; ++i)
                {
                    if (Checkfoe.Checked)
                    {
                        for (int j = 0; j < Listprodassign.Items.Count; ++j)
                        {
                            ListEmpAssigned.SelectedIndex = i;
                            string   pname = ListEmpAssigned.SelectedItem.Value;
                            string[] arr1  = pname.Split(new char[] { ':' }, pname.Length);
                            string   sql1  = "select cust_ID from customer where cust_Name='" + arr1[0] + "' and cust_Type='" + arr1[1] + "'";
                            dbobj.SelectQuery(sql1, ref SqlDtr);
                            while (SqlDtr.Read())
                            {
                                obj.cust_id = SqlDtr.GetValue(0).ToString();
                            }
                            //							obj.Deletefoecust();
                            //*****************
                            Listprodassign.SelectedIndex = j;
                            string   prodname = Listprodassign.SelectedItem.Value;
                            string[] arr2     = prodname.Split(new char[] { ':' }, prodname.Length);
                            string   sql2     = "select prod_ID from products where prod_Name='" + arr2[0] + "' and pack_Type='" + arr2[1] + "'";
                            dbobj.SelectQuery(sql2, ref SqlDtr1);
                            while (SqlDtr1.Read())
                            {
                                obj.prod_id = SqlDtr1.GetValue(0).ToString();
                            }
                            obj.InsertFOEdiscountEntry();
                            SqlDtr1.Close();
                            //*******************
                        }
                    }
                    else
                    {
                        ListEmpAssigned.SelectedIndex = i;
                        string   pname = ListEmpAssigned.SelectedItem.Value;
                        string[] arr1  = pname.Split(new char[] { ':' }, pname.Length);
                        string   sql1  = "select cust_ID from customer where cust_Name='" + arr1[0] + "' and cust_Type='" + arr1[1] + "'";
                        dbobj.SelectQuery(sql1, ref SqlDtr);
                        while (SqlDtr.Read())
                        {
                            obj.cust_id = SqlDtr.GetValue(0).ToString();
                            //obj.InsertFOEdiscount();
                        }
                        obj.prod_id = "0";
                        obj.InsertFOEdiscountEntry();
                        SqlDtr.Close();
                    }
                }
                MessageBox.Show("F-OE discount Saved");
                Clear();
                GetNextschemeID();
                getCustandProd();
                CreateLogFiles.ErrorLog("Form:fleet/oe discountEntry.aspx,Method:btnSave_Click");
            }
            catch (Exception ex)
            {
                CreateLogFiles.ErrorLog("Form:fleet/oe discountEntry.aspx,Method:btnSave_Click EXCEPTION " + ex.Message + "  User  " + uid);
            }
        }