Exemplo n.º 1
0
        public DataTable InsertRecord(Objects.Recovery obj)
        {
            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "SP_RecoveryInsert";

                cmd.Parameters.AddWithValue("@RecoveryDate", obj.RecoveryDate);
                cmd.Parameters.AddWithValue("@SalesmanID", obj.SalesmanID);
                cmd.Parameters.AddWithValue("@TotalRecovery", obj.TotalRecovery);
                cmd.Parameters.AddWithValue("@UserID", obj.UserID);
                cmd.Parameters.AddWithValue("@Remarks", obj.Remarks);

                return(new Database(connectionstring).ExecuteForDataTable(cmd));
            }
            catch (Exception exc)
            {
                throw exc;
            }
        }
Exemplo n.º 2
0
        public void UpdateRecord(Objects.Recovery obj)
        {
            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "SP_RecoveryUpdate";

                cmd.Parameters.AddWithValue("@RecoveryID", obj.RecoveryID);
                cmd.Parameters.AddWithValue("@RecoveryDate", obj.RecoveryDate);
                cmd.Parameters.AddWithValue("@SalesmanID", obj.SalesmanID);
                cmd.Parameters.AddWithValue("@TotalRecovery", obj.TotalRecovery);
                cmd.Parameters.AddWithValue("@UserID", obj.UserID);
                cmd.Parameters.AddWithValue("@Remarks", obj.Remarks);

                new Database(connectionstring).ExecuteNonQueryOnly(cmd);
            }
            catch (Exception exc)
            {
                throw exc;
            }
        }
Exemplo n.º 3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                int vSalesmanID = 0;

                int.TryParse(cboSalesman.SelectedValue.ToString(), out vSalesmanID);

                if (vSalesmanID == 0)
                {
                    MessageBox.Show("Please Select Salesman", "Information Missing");
                    cboSalesman.Focus();
                    return;
                }

                if (Grid.Rows.Count == 0)
                {
                    MessageBox.Show("Please Insert Recovery Customers", "Detail Missing");
                    txtCustomerID.Focus();
                    return;
                }

                decimal vTotal = 0;
                decimal.TryParse(txtTotal.Text, out vTotal);

                Objects.Recovery BAL = new Objects.Recovery();

                BAL.RecoveryID    = Int64.Parse(txtInvNo.Text);
                BAL.RecoveryDate  = dtRecoveryDate.Value;
                BAL.SalesmanID    = vSalesmanID;
                BAL.TotalRecovery = vTotal;
                BAL.Remarks       = txtRemarks.Text;
                BAL.UserID        = vUserID;

                if (vOpenMode)
                {
                    objDAL.UpdateRecord(BAL);
                    objDAL.DeleteRecordBody(Int64.Parse(txtInvNo.Text));
                }
                else
                {
                    DataTable dt = objDAL.InsertRecord(BAL);
                    BAL.RecoveryID = Int64.Parse(dt.Rows[0]["RecoveryID"].ToString());
                }

                //Save Detail
                foreach (DataGridViewRow dr in Grid.Rows)
                {
                    if (dr.Cells[0].Value != null)
                    {
                        Objects.RecoveryBody objBody = new Objects.RecoveryBody();
                        objBody.RecoveryID     = BAL.RecoveryID;
                        objBody.CustomerID     = Int64.Parse(dr.Cells["PartyID"].Value.ToString());
                        objBody.AmountRecoverd = decimal.Parse(dr.Cells["AmountRecoverd"].Value.ToString(), System.Globalization.NumberStyles.AllowDecimalPoint);
                        objBody.Remarks        = string.Empty;

                        objDAL.InsertRecordBody(objBody);
                    }
                }

                Message.ShowMessage(MyMessages.MessageType.SaveRecord);
                ClearFields();
            }
            catch (Exception exc)
            {
                Message.ShowMessage(MyMessages.MessageType.Error, exc.Message);
            }
        }