Ejemplo n.º 1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Do you want to Save current record ?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
            {
                ;
            }
            {
                BillingDataTypes.BillingDataType _SaveData = new BillingDataTypes.BillingDataType();
                string respond = SetDataToPayBill(out _SaveData);
                if (!MyBill.ExistBilling(_SaveData.BillNo, _SaveData.PayToID))
                {
                    int BillStatus = -1;
                    int SupID      = Convert.ToInt32(supid);
                    BillStatus = MyBill.GetBillStatus(cmbGRN.Text, Convert.ToInt32(supid));
                    if (BillStatus == 0)
                    {
                        if (respond == "True")
                        {
                            respond = MyBill.Save(_SaveData);

                            if (respond == "True")
                            {
                                //Edit by manjula
                                //********************************* update tblmaterials
                                bool        res = false;
                                LINKPayment objList;


                                for (int i = 0; i < dtpGRNDetals.Rows.Count; i++)
                                {
                                    if (Convert.ToBoolean(dtpGRNDetals.Rows[i].Cells[0].Value) == true)
                                    {
                                        objList              = new LINKPayment();
                                        objList.Status       = 9;
                                        objList.GRNNo        = cmbGRN.SelectedValue.ToString();
                                        objList.MaterialCode = dtpGRNDetals.Rows[i].Cells["MaterialCode"].Value.ToString();

                                        res = objService.SetMaterialStatus(objList);
                                    }
                                }


                                Program.InformationMessage("Record saved successfully");
                                // LoadBillList(MyCommon.GetSelectedID(cmbSupplier, true));

                                LoadBillList(SupID.ToString());

                                //Added by manju
                                LINKPayment objLink = new LINKPayment();
                                objLink.SupName = cmbSupplier.SelectedValue.ToString();
                                objLink.Status  = 0;
                                LoadGRN(objLink);

                                dtpGRNDetals.Columns.Clear();
                                dtpGRNDetals.DataSource = null;
                            }
                            else
                            {
                                Program.VerningMessage(respond);
                            }
                        }
                        else
                        {
                            Program.VerningMessage(respond);
                        }
                    }
                    else
                    {
                        switch (BillStatus)
                        {
                        case 2:
                            Program.VerningMessage("You cannot chage any details of this bill , Tt is already approved");
                            break;

                        case 3:
                            Program.VerningMessage("You cannot chage any details of this bill, It is already accounted");
                            break;

                        default:
                            break;
                        }
                    }
                }
                else
                {
                    Program.VerningMessage("Use Update Button to update details");
                }
            }
        }